﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WinFormsApp_ListViewUsageTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; //不显示列的标头
            this.listView2.MinimumSize = new Size(150, 200); //给定最小宽度为150,给列的宽度为100(要小于listview的宽度,否则会出现水平滚动条)
            listView2.FullRowSelect = true; //可选中整行
            string[] directory = Directory.GetDirectories("F:\\windows"); //将windows文件夹下的所有文件夹显示出来(像qq列表一样)
            foreach (string s in directory)
            {
                this.listView2.Items.Add(s.Substring(s.LastIndexOf('\\') + 1), 0);
            }
            this.listView2.Scrollable = true; //显示滚动条
            this.listView2.SmallImageList = this.imageList1;
            this.listView2.View = View.SmallIcon;

            this.listView2.SizeChanged += new EventHandler(listView2_SizeChanged);
        }

        void listView2_SizeChanged(object sender, EventArgs e)
        {
            this.label1.Text = listView2.Width.ToString();

        }
    }
}
